package com.nwpu.intimacy.baidumapsdk.model;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;

import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.nwpu.intimacy.R;


public class LocationInfor {
	
	private static BitmapDescriptor bdA = BitmapDescriptorFactory
			.fromResource(R.drawable.icon_marka);
	
	private String username;
	private Bitmap mBitmap;
	private LatLng location;
	private Marker marker;
	private OverlayOptions overlay;
	
	
	public LocationInfor(String iUsername, String portrait, 
			double iLgt, double ltt) {
		
		this.username = iUsername;
		this.mBitmap = StringtoBitmap(portrait);
		this.location = new LatLng(iLgt, ltt);
		this.overlay = new MarkerOptions().position(location).icon(bdA)
				.zIndex(9).draggable(true);
	}
	
	@SuppressLint("NewApi")
	public Bitmap StringtoBitmap(String string){
	    //将字符串转换成Bitmap类型
	    Bitmap bitmap=null;
	    try {
		    byte[]bitmapArray;
		    bitmapArray=Base64.decode(string, Base64.DEFAULT);
		    bitmap=BitmapFactory.decodeByteArray(
		    		bitmapArray, 0, bitmapArray.length);
		    
		    CacheUtil.WriteToFile("lw", bitmap, "gao");
		    
		} catch (Exception e) {
			e.printStackTrace();
		}
	    
	    return bitmap;
	}

	
	public LocationInfor() {
		username = "";
		mBitmap = null;
	}
	
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public Bitmap getmBitmap() {
		return mBitmap;
	}
	public void setmBitmap(Bitmap mBitmap) {
		this.mBitmap = mBitmap;
	}


	public LatLng getLocation() {
		return location;
	}

	public void setLocation(LatLng location) {
		this.location = location;
	}
	
	public Marker getMarker() {
		return marker;
	}

	public void setMarker(Marker marker) {
		this.marker = marker;
	}
	
	public OverlayOptions getOverlay() {
		return overlay;
	}

	public void setOverlay(OverlayOptions overlay) {
		this.overlay = overlay;
	}
	
	public String toString() {
		return "username:  " + username + " " + 
			   "longitude: " + location.longitude + " " + 
			   "latitude:  " + location.latitude;
	}
	
	

	
}
